<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.biz.utils.ConfigUtil" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
    String resoursUrl = ConfigUtil.get("RESOURCES_URL");
%>
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>我的优惠券</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="format-detection" content="telephone=no" />
  <jsp:include page="/jsp/inc_head.jsp"></jsp:include>
<style>
[data-am-widget=tabs] {
    margin:0;
}
.am-tabs-default .am-tabs-nav>.am-active a {
    background-color:inherit;
    color: #fff;
	opacity:1;
}
.am-tabs-default .am-tabs-nav {
    background-color: #ff6060;
}
.am-tabs-default .am-tabs-nav a {
    color: #fff;
	opacity:0.7;
}
.am-tabs-bd {
    border:0;
}
.am-tabs-bd .am-tab-panel {
    padding:0;
}

</style>
</head>

<body style="padding-bottom:50px;">
<div class="am-g">
	<div data-am-widget="tabs" class="am-tabs am-tabs-default">
        <ul class="am-tabs-nav am-cf">
            <li class="am-active" onClick="queryCoupons(0);" ><a href="[data-tab-panel-0]">全部</a></li>
            <li class="" onClick="queryCoupons(1);" ><a href="[data-tab-panel-1]">已使用</a></li>
            <li class="" onClick="queryCoupons(2);"><a href="[data-tab-panel-2]">未使用</a></li>
            <li class="" onClick="queryCoupons(3);"><a href="[data-tab-panel-3]">已过期</a></li>
        </ul>
        
        <div class="am-tabs-bd">
            <!-- 全部 -->
            <div data-tab-panel-0 id="loop0" class="am-tab-panel am-active">

            </div>

             <!-- 已使用 -->
            <div data-tab-panel-1 id="loop1" class="am-tab-panel ">

            </div>

            <!-- 未使用 -->
            <div data-tab-panel-2 id="loop2" class="am-tab-panel ">

            </div>

            <!-- 已过期 -->
            <div data-tab-panel-3 id="loop3" class="am-tab-panel">

            </div>

        </div>
	</div>
</div>
<script>
    var ajaxpath="${pageContext.request.contextPath}";
    $(function () {
          queryCoupons(0);
    });
    
    function queryCoupons(type){
          var url=ajaxpath+"/coupons/queryMyCoupons.do?type="+type;
          $.get(url,function(coupons_list){
               if(coupons_list.length!=0){
		               var html="";
		               $.each(coupons_list,function(i){
		                      if(this.state==2){
		                           html+='<div class="am-u-sm-12 myyhq_quan">'+
		                                 '<div class="am-u-sm-12 am-pad-none yhq_up1">'+
		                                 '<div class="am-u-sm-6">'+
		                                 '￥<span class="yhq_num">'+this.reduce_cost+'</span>'+
		                                 '</div>'+
		                                 '<div class="am-u-sm-6 am-text-right">'+
		                                 '<div class="yhq_usetj">满'+this.least_cost+'可用</div>'+
		                                 '<div class="yhq_yhmtet1">优惠码</div>'+
		                                 '<div class="yhq_yhmtet1">'+this.id+'</div>'+
		                                 '</div>'+
		                                 '</div>'+
		                                 '<div class="am-u-sm-12 am-pad-none yhq_down">'+
		                                 '<div class="am-u-sm-10 am-pad-none">'+
		                                 '有效期:'+this.startDate+'~'+this.endDate+
		                                 '</div>'+
		                                 '<div class="am-u-sm-2 am-pad-none am-text-right">'+
		                                 '<span class="wsy_col1">已使用</span>'+
		                                 '</div>'+
		                                 '</div>'+
		                                 '</div>';
		                      }else{
		                           var endTime=new Date(this.endDate).getTime();
					               var currentTime=new Date().getTime();
					               var moneyTerm=86400000;
					               endTime=eval(endTime+moneyTerm);
					               if(endTime>=currentTime){
					               	   html+='<div class="am-u-sm-12 myyhq_quan">'+
					               	         '<div class="am-u-sm-12 am-pad-none yhq_up">'+
					               	         '<div class="am-u-sm-6">'+
					               	         '￥<span class="yhq_num">'+this.reduce_cost+'</span>'+
					               	         '</div>'+
					               	         '<div class="am-u-sm-6 am-text-right">'+
					               	         '<div class="yhq_usetj">满'+this.least_cost+'可用</div>'+
					               	         '<div class="yhq_yhmtet">优惠码</div>'+
					               	         '<div class="yhq_yhmtet">'+this.id+'</div>'+
					               	         '</div>'+
					               	         '</div>'+
					               	         '<div class="am-u-sm-12 am-pad-none yhq_down">'+
					               	         '<div class="am-u-sm-10 am-pad-none">'+
					               	         '有效期:'+this.startDate+'~'+this.endDate+
					               	         '</div>'+
					               	         '<div class="am-u-sm-2 am-pad-none am-text-right">'+
					               	         '<span class="wsy_col">未使用</span>'+
					               	         '</div>'+
					               	         '</div>'+
					               	         '</div>';
					               }else{
					               	   html+='<div class="am-u-sm-12 myyhq_quan">'+
			                                 '<div class="am-u-sm-12 am-pad-none yhq_up1">'+
			                                 '<div class="am-u-sm-6">'+
			                                 '￥<span class="yhq_num">'+this.reduce_cost+'</span>'+
			                                 '</div>'+
			                                 '<div class="am-u-sm-6 am-text-right">'+
			                                 '<div class="yhq_usetj">满'+this.least_cost+'可用</div>'+
			                                 '<div class="yhq_yhmtet1">优惠码</div>'+
			                                 '<div class="yhq_yhmtet1">'+this.id+'</div>'+
			                                 '</div>'+
			                                 '</div>'+
			                                 '<div class="am-u-sm-12 am-pad-none yhq_down">'+
			                                 '<div class="am-u-sm-10 am-pad-none">'+
			                                 '有效期:'+this.startDate+'~'+this.endDate+
			                                 '</div>'+
			                                 '<div class="am-u-sm-2 am-pad-none am-text-right">'+
			                                 '<span class="wsy_col1">已过期</span>'+
			                                 '</div>'+
			                                 '</div>'+
			                                 '</div>';
					               }
		                      }
		               });
		               if(type==0){
						 	$("#loop0").html(html);
					   }else if(type==1){
						 	$("#loop1").html(html);
					   }else if(type==2){
						 	$("#loop2").html(html);
					   }else if(type==3){
						 	$("#loop3").html(html);
					   }
			   }else{
			   		   var html="";
			   		   html+='<div class="am-u-sm-12 am-text-center" style="margin-top:70px;">'+
                	         '<img src="<%=resoursUrl%>resources/assets/image/myyhq_wkpic.png" width="150"/>'+
                             '</div>';
			   		   if(type==0){
						 	$("#loop0").html(html);
					   }else if(type==1){
						 	$("#loop1").html(html);
					   }else if(type==2){
						 	$("#loop2").html(html);
					   }else if(type==3){
						 	$("#loop3").html(html);
					   }
			   }
          });
    }
</script>

</body>
</html>